<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="id" name="id" value="${sign.id!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">位置名字</label>
              <div class="layui-input-block">
                  <input type="text" id="locationName" name="locationName" value="${sign.locationName!}"  autocomplete="off" placeholder="请输入位置名字"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">签到照片</label>
              <div class="layui-input-block">
                  <input type="text" id="fileName" name="fileName" value="${sign.fileName!}"  autocomplete="off" placeholder="请输入签到照片"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">年</label>
              <div class="layui-input-block">
                  <input type="text" id="y" name="y" value="${sign.y!}"  autocomplete="off" placeholder="请输入年"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">月</label>
              <div class="layui-input-block">
                  <input type="text" id="m" name="m" value="${sign.m!}"  autocomplete="off" placeholder="请输入月"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">日</label>
              <div class="layui-input-block">
                  <input type="text" id="d" name="d" value="${sign.d!}"  autocomplete="off" placeholder="请输入日"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">latitude</label>
              <div class="layui-input-block">
                  <input type="text" id="latitude" name="latitude" value="${sign.latitude!}"  autocomplete="off" placeholder="请输入latitude"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">longitude</label>
              <div class="layui-input-block">
                  <input type="text" id="longitude" name="longitude" value="${sign.longitude!}"  autocomplete="off" placeholder="请输入longitude"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">用户id外键</label>
              <div class="layui-input-block">
                  <input type="text" id="userId" name="userId" value="${sign.userId!}"  autocomplete="off" placeholder="请输入用户id外键"
                         class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">0 上午 1=下午</label>
              <div class="layui-input-block">
                  <input type="text" id="isPm" name="isPm" value="${sign.isPm!}"  autocomplete="off" placeholder="请输入0 上午 1=下午"
                         class="layui-input">
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         id:$("#id").val(),
                         locationName:$("#locationName").val(),
                         fileName:$("#fileName").val(),
                         y:$("#y").val(),
                         m:$("#m").val(),
                         d:$("#d").val(),
                         latitude:$("#latitude").val(),
                         longitude:$("#longitude").val(),
                         userId:$("#userId").val(),
                           isPm:$("#isPm").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/app/sign/editSign",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/app/sign/main.html"
                    } else {

                    }
                }
            });
        })







        function check(){
                   if($("#locationName").val().length<1){
                       layer.msg("请输入位置名字");
                       return false;
                   }
                   if($("#fileName").val().length<1){
                       layer.msg("请输入签到照片");
                       return false;
                   }
                   if($("#y").val().length<1){
                       layer.msg("请输入年");
                       return false;
                   }
                   if($("#m").val().length<1){
                       layer.msg("请输入月");
                       return false;
                   }
                   if($("#d").val().length<1){
                       layer.msg("请输入日");
                       return false;
                   }
                   if($("#latitude").val().length<1){
                       layer.msg("请输入latitude");
                       return false;
                   }
                   if($("#longitude").val().length<1){
                       layer.msg("请输入longitude");
                       return false;
                   }
                   if($("#userId").val().length<1){
                       layer.msg("请输入用户id外键");
                       return false;
                   }
                   if($("#isPm").val().length<1){
                       layer.msg("请输入0 上午 1=下午");
                       return false;
                   }
        }
    });

</script>
</body>
</html>